#ifndef T_BOX_INPUT_H
#define T_BOX_INPUT_H

#include "t_box_player.h"

class T_Box_Input
{
protected:
    ByteIOContext m_bioc;
    //quint8 *m_buffer;
public:
    virtual bool isValid() = 0;
    virtual T_Box_Player_Context *getAVFormatContext2() = 0;
protected:
    QString p_seek_whence_name(int whence);
};

class T_Box_Input_File : public T_Box_Input
{
public:
    static const int c_buffer_size = 32768;
    quint8 *m_buffer;
    QFile m_file;
    T_Box_Input_File(QString a_filename);
    ~T_Box_Input_File();
    virtual bool isValid();
    AVInputFormat *getAVInputFormat();
    ByteIOContext *getByteIOContext();
    AVFormatContext	*getAVFormatContext();
    virtual T_Box_Player_Context *getAVFormatContext2();
    int read_packet(uint8_t *buf, int buf_size);
    int64_t seek(int64_t offset, int whence);
protected:
    static int callback_read_packet(void *opaque, uint8_t *buf, int buf_size)
    {
        T_Box_Input_File *self = (T_Box_Input_File *)opaque;
        return self->read_packet(buf, buf_size);
    }
    static int64_t callback_seek(void *opaque, int64_t offset, int whence)
    {
        T_Box_Input_File *self = (T_Box_Input_File *)opaque;
        return self->seek(offset, whence);
    }
#if 0x0
private:
    QString p_seek_whence_name(int whence);
#endif
};

#endif // T_BOX_INPUT_H
